package com.example.gbuffer.Component.Camera;

import android.opengl.Matrix;

public abstract class Camera {
    protected float[] m_eye = new float[3];
    protected float[] m_center = new float[3];
    protected float[] m_up = new float[3];

    public float[] lookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) {
        float[] mat = new float[16];
        Matrix.setLookAtM(mat, 0,
                eyeX,eyeY,eyeZ,
                centerX,centerY, centerZ,
                upX,upY,upZ);

        m_eye[0] = eyeX;
        m_eye[1] = eyeY;
        m_eye[2] = eyeZ;

        m_center[0] = centerX;
        m_center[1] = centerY;
        m_center[2] = centerZ;

        m_up[0] = upX;
        m_up[1] = upY;
        m_up[2] = upZ;

        return mat;
    }

    public float[] getEye(){
        return new float[]{
                m_eye[0],
                m_eye[1],
                m_eye[2]
        };
    }

    public float[] getCenter(){
        return new float[]{
                m_center[0],
                m_center[1],
                m_center[2]
        };
    }

    public float[] getUp(){
        return new float[]{
                m_up[0],
                m_up[1],
                m_up[2]
        };
    }

    public float[] getLookAt() {
        return lookAt(m_eye[0], m_eye[1], m_eye[2], m_center[0], m_center[1], m_center[2], m_up[0], m_up[1], m_up[2]);
    }
}
